// house_pkg/pages/room/index.ts
Page({
  data:{
    point: '',
    building: '',
    rooms: []
  },
  onLoad({ point, building }) {
    console.log(point, building)
    // 创建房间
    this.fake(point, building)
  },
  fake(point, building){
    // 生成测试数据
    const size = Math.floor(Math.random() * 5) + 4
    const rooms = []
    console.log('size',size)
    // 
    for(let i = 0; i < size; i++){
      // 楼层号生成1~20
      const floor = Math.floor(Math.random() * 19) + 1
      // 具体的房间号生成1-3
      const number = Math.floor(Math.random() * 2) + 1
      // 201 202 203
      const room  = [floor, 0,number].join('')
      // 检测是否有重复的房间号
      if(!rooms.includes(room)){
        // 记录生成完成的房间号
        rooms.push(room)
      }
    }
    this.setData({ rooms ,point, building})
  }
})
